from typing import List, Dict, Any, Optional

class Tool:
    """工具基类，所有工具都应继承此类"""

    def get_name(self) -> str:
        """返回工具名称"""
        raise NotImplementedError

    def get_description(self) -> str:
        """返回工具描述"""
        raise NotImplementedError

    def get_parameters(self) -> Dict[str, Any]:
        """返回工具参数定义"""
        return {}

    def execute(self, arguments: Dict[str, Any]) -> str:
        """执行工具并返回结果"""
        raise NotImplementedError

    def to_dict(self) -> Dict[str, Any]:
        """转换为工具定义字典"""
        return {
            "type": "function",
            "function": {
                "name": self.get_name(),
                "description": self.get_description(),
                "parameters": self.get_parameters()
            }
        }